<%--
  Created by IntelliJ IDEA.
  User: 12290
  Date: 2020/12/28
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品详情</title>
    <link rel="stylesheet" type="text/css" href="/plugins/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/css/nav.css">
    <link rel="stylesheet" type="text/css" href="/plugins/layui/css/layui.css">
</head>
<body>

    <%@include file="../common/nav.jsp"%>

    <input type="hidden" value="${user.userId}" id="userId_hidden">
    <input type="hidden" value="${goods.goodsName}" id="goodsName_hidden">
    <input type="hidden" value="${goods.goodsId}" id="goodsId_hidden">
    <input type="hidden" value="${goods.goodsPrice}" id="goodsPrice_hidden">
    <input type="hidden" value="${goods.goodsImgs}" id="goodsImgs_hidden">

    <div class="container">
        <div class="row">
            <div class="col-md-3"></div>

            <div class="col-md-9">
                <form class="form-horizontal" role="form">
                    <input type="hidden" value="${goods.goodsId}" name="id">

                    <div class="form-group">
                        <label class="col-sm-1 control-label"></label>
                        <div class="col-sm-11">
                            <img src="/imgs/${goods.goodsImgs}" style="width: 400px;height: 400px">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">商品名：</label>
                        <div class="col-sm-9">
                            <label class="col-sm-4 control-label" style="padding-right: -100px">${goods.goodsName}</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">价格：</label>
                        <div class="col-sm-9">
                            <label class="col-sm-4 control-label" style="padding-left: -100px">${goods.goodsPrice}</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">介绍：</label>
                        <div class="col-sm-9">
                            <label class="col-sm-4 control-label" style="padding-left: -100px">${goods.goodsRemark}</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-5 control-label">
                            <label class="col-sm-5 control-label" style="padding-left: 100px">
                                <button type="button" class="btn btn-primary btn-group-lg"onclick="addproduct(${goods.goodsId})"
                                >加入购物车</button>
                            </label>
                        </label>
                        <div class="col-sm-7">
                            <label class="col-sm-1 control-label" style="padding-right: 100px">
                                <button type="button" class="btn btn-primary btn-group-lg"
                                        onclick="exit()"
                                >返回</button>
                            </label>
                    </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script src="/plugins/jquery/jquery.min.js"></script>
    <script src="/plugins/bootstrap/js/bootstrap.js"></script>
    <script src="/plugins/layui/layui.js"></script>

    <script>
        function addproduct(goodsId){


            $.post("/product/insert",{goodsId:goodsId},function (result) {
                alert(result.msg);
            });
        }
        //     let userid = $("#userid_hidden").val();
        //     let productname =$("#productname_hidden").val();
        //     let productid = $("#productid_hidden").val();
        //     let price =$("#price_hidden").val();
        //     let number = $("#J_IptAmount").val();
        //     let imgurl = $("#imgurl_hidden").val();
        //
        //     if (userid == "") {
        //         window.location = "/mvc/user/login";
        //     }else {
        //         $.post("/mvc/shoppingcart/addcart",{userid:userid,productid:productid,productname:productname,price:price,number:number,imgurl:imgurl},function (data){
        //             layui.use('layer', function(){
        //                 var layer = layui.layer;
        //                 layer.msg(data.msg,{icon:6})
        //             });
        //         })
        //     }
        // }

    </script>
    <script>
    function exit(){
    window.location = "/product/index";
   }
    </script>
</body>
</html>